1. Field
Embodiments relate to allocation and management of memory in runtime environments for computer applications.
2. Related Art
The runtime environment for computer (e.g., .NET-based) applications manages diverse memory tasks. One of the tasks includes the management of heap memory. Typically the runtime environment manages two heaps. A first heap for small objects (SmallObjectHeap, hereinafter SOH) and a second heap for large objects (LargeObjectHeap, hereinafter LOH). All objects which require a large amount of memory (e.g., more memory than 85000 bytes) are stored in the LOH. Otherwise the objects are allocated to the SOH.
Runtime environments with automatic memory management typically include a so-called GarbageCollector (GC). The GC ensures memory that is no longer required is released at certain times. In addition, the GC compacts the heap. Compacting the heap includes defragmenting the heap to close memory gaps by moving objects in the heap memory around to fill empty gaps. Compacting the heap, however, is only applicable to the SOH. For performance reasons, the LOH is not compacted. Therefore, with some applications, the LOH requires significantly more memory due to the strong fragmentation than is actually required by the large memory requirement objects.
The use of strings in the context of runtime environment for computer (e.g., .NET-based) applications is a fundamental programming construct. Depending on the application, the string objects stored in the memory can have a considerable quantity and size. Therefore, special attention is required for these string objects with regard to their representation in the memory and the effect of their use on the memory. Large string objects (e.g., greater than 85000 bytes) are also stored in the LOH. If the high-frequency creation of short-lived large string objects is inappropriately combined with the low-frequency creation of long-lived large string objects, considerable LOH fragmentation will occur so that large fractions of the memory remain unused.